﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BaMusaSoft.RPS.DataModel;
using BaMusaSoft.RPS.DataModel.Repositories;
using BaMusaSoft.RPS.ViewModel.Infrastructure;

namespace BaMusaSoft.RPS.ViewModel
{
    public class AddCustomerViewModel: Workspace
    {
        IUnitOfWork _unitOfWork;
        CustomersRepository _repository;
        ObservableCollection<Customer> _customers;
        public AddCustomerViewModel(IUnitOfWork unitOfWork)
        {
            if (unitOfWork == null) throw new ArgumentNullException("unitOfWork");
            _unitOfWork = unitOfWork;
            _repository = _unitOfWork.Customers as CustomersRepository;
            Customers = GetCustomers();
            
        }

        private ObservableCollection<Customer> GetCustomers()
        {
           return new ObservableCollection<Customer>( _repository.GetAll());
        }
        public ObservableCollection<Customer> Customers
        {
            get { return _customers; }
            private set
            {
                _customers = value;
                RaisePropertyChanged("Customers");
            }
        }
        public Customer SelectedCustomer
        {
            get;
            set;
        }
        
        #region "Base"

        public override string DisplayName
        {
            get
            {
                throw new NotImplementedException();
            }
            protected set
            {
                throw new NotImplementedException();
            }
        }

        public override bool HasChanges
        {
            get { throw new NotImplementedException(); }
        }
        #endregion
    }
}
